Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 3 - Finder Commands / Command Definitions


Exists

An Exists command is a request to determine whether the object specified by a reference exists. The Finder version of the Exists command is identical to the standard version described in the AppleScript Language Guide.

SYNTAX
exists referenceToObject
referenceToObject exists 
PARAMETER
referenceToObject
A reference to the object to find or a list of references.
Class: Reference or list of references
RESULT
A Boolean value. If true, all of the objects referred to by referenceToObject exist. If false, one or more of the objects referred to by referenceToObject do not exist.

EXAMPLE
This script checks whether a disk named Storage is mounted and, if it is, copies all files from the folder Correspondence whose modification dates are more than 30 days old to disk Storage and deletes the originals.

tell application "Finder"   if exists disk "Storage" then
      set aMonthAgo to (current date) - (30 * days)
      copy (every item in folder "Correspondence" of startup disk ¬
         whose modification date < aMonthAgo) ¬
         to folder "Old Letters" of disk "Storage"      delete (every item in folder "Correspondence" of startup disk ¬
         whose modification date < aMonthAgo)
   else
      display dialog "The Storage cartridge isn't mounted."   end if
end tell
Note that you can't use the Move command instead of the Copy and Delete commands in this script, because the Move command changes to Copy when moving items between volumes.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996